//
// DyneTK, the Dyne Toolkit
// Copyright (C) 2007 Matthias Melcher
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//

// generated by Fast Light User Interface Designer (fluid) version 1.0300

#include "Fldtk_Dialogs.h"

void Fldtk_New_Slot_Dialog::cb_wSpecific_i(Fl_Menu_Button*, void*) {
  wSlotName->value(wSpecific->menu()[wSpecific->value()].label());
wSlotName->do_callback();
}
void Fldtk_New_Slot_Dialog::cb_wSpecific(Fl_Menu_Button* o, void* v) {
  ((Fldtk_New_Slot_Dialog*)(o->parent()))->cb_wSpecific_i(o,v);
}

void Fldtk_New_Slot_Dialog::cb_wMethods_i(Fl_Menu_Button*, void*) {
  wSlotName->value(wMethods->menu()[wMethods->value()].label());
wSlotName->do_callback();
}
void Fldtk_New_Slot_Dialog::cb_wMethods(Fl_Menu_Button* o, void* v) {
  ((Fldtk_New_Slot_Dialog*)(o->parent()))->cb_wMethods_i(o,v);
}

void Fldtk_New_Slot_Dialog::cb_wAttributes_i(Fl_Menu_Button*, void*) {
  wSlotName->value(wAttributes->menu()[wAttributes->value()].label());
wSlotName->do_callback();
}
void Fldtk_New_Slot_Dialog::cb_wAttributes(Fl_Menu_Button* o, void* v) {
  ((Fldtk_New_Slot_Dialog*)(o->parent()))->cb_wAttributes_i(o,v);
}

void Fldtk_New_Slot_Dialog::cb_wSlotName_i(Fl_Input*, void*) {
  if (*wSlotName->value()) {
  wAdd->activate();
} else {
  wAdd->deactivate();
}
const char *help = dtkPlatform->getHelp(tmpl_, wSlotName->value());
wHelp->copy_label(help);
}
void Fldtk_New_Slot_Dialog::cb_wSlotName(Fl_Input* o, void* v) {
  ((Fldtk_New_Slot_Dialog*)(o->parent()))->cb_wSlotName_i(o,v);
}

void Fldtk_New_Slot_Dialog::cb_Number_i(Fl_Menu_*, char*) {
  // FIXME: or INTG ?;
}
void Fldtk_New_Slot_Dialog::cb_Number(Fl_Menu_* o, char* v) {
  ((Fldtk_New_Slot_Dialog*)(o->parent()->user_data()))->cb_Number_i(o,v);
}

Fl_Menu_Item Fldtk_New_Slot_Dialog::menu_wEditor[] = {
 {"Evaluate", 0,  0, (void*)("EVAL"), 0, FL_NORMAL_LABEL, 0, 12, 0},
 {"Script", 0,  0, (void*)("SCPT"), 0, FL_NORMAL_LABEL, 0, 12, 0},
 {"Text", 0,  0, (void*)("TEXT"), 0, FL_NORMAL_LABEL, 0, 12, 0},
 {"Number", 0,  (Fl_Callback*)Fldtk_New_Slot_Dialog::cb_Number, (void*)("NUMB"), 0, FL_NORMAL_LABEL, 0, 12, 0},
 {"Boolean", 0,  0, (void*)("BOOL"), 0, FL_NORMAL_LABEL, 0, 12, 0},
 {"Rectangle", 0,  0, (void*)("RECT"), 0, FL_NORMAL_LABEL, 0, 12, 0},
 {"Picture", 0,  0, (void*)("PICT"), 0, FL_NORMAL_LABEL, 0, 12, 0},
 {0,0,0,0,0,0,0,0,0}
};

void Fldtk_New_Slot_Dialog::cb_wAdd_i(Fl_Button*, void*) {
  tmpl_->addSlot(wSlotName->value(), (char*)wEditor->menu()[wEditor->value()].user_data());
}
void Fldtk_New_Slot_Dialog::cb_wAdd(Fl_Button* o, void* v) {
  ((Fldtk_New_Slot_Dialog*)(o->parent()))->cb_wAdd_i(o,v);
}

void Fldtk_New_Slot_Dialog::cb_wDone_i(Fl_Button*, void*) {
  hide();
}
void Fldtk_New_Slot_Dialog::cb_wDone(Fl_Button* o, void* v) {
  ((Fldtk_New_Slot_Dialog*)(o->parent()))->cb_wDone_i(o,v);
}
Fldtk_New_Slot_Dialog::Fldtk_New_Slot_Dialog(int X, int Y, int W, int H, const char *L)
  : Fl_Window(X, Y, W, H, L) {
  _Fldtk_New_Slot_Dialog();
}

Fldtk_New_Slot_Dialog::Fldtk_New_Slot_Dialog(int W, int H, const char *L)
  : Fl_Window(0, 0, W, H, L) {
  clear_flag(16);
  _Fldtk_New_Slot_Dialog();
}

void Fldtk_New_Slot_Dialog::_Fldtk_New_Slot_Dialog() {
this->box(FL_FLAT_BOX);
this->color(FL_BACKGROUND_COLOR);
this->selection_color(FL_BACKGROUND_COLOR);
this->labeltype(FL_NO_LABEL);
this->labelfont(0);
this->labelsize(14);
this->labelcolor(FL_FOREGROUND_COLOR);
this->align(FL_ALIGN_TOP);
this->when(FL_WHEN_RELEASE);
{ wTemplateProto = new Fl_Box(5, 8, 390, 22);
  wTemplateProto->labelfont(1);
  wTemplateProto->labelsize(12);
} // Fl_Box* wTemplateProto
{ wSpecific = new Fl_Menu_Button(65, 40, 84, 20, "Specific");
  wSpecific->labelsize(12);
  wSpecific->textsize(12);
  wSpecific->callback((Fl_Callback*)cb_wSpecific);
} // Fl_Menu_Button* wSpecific
{ wMethods = new Fl_Menu_Button(158, 40, 84, 20, "Methods");
  wMethods->labelsize(12);
  wMethods->textsize(12);
  wMethods->callback((Fl_Callback*)cb_wMethods);
} // Fl_Menu_Button* wMethods
{ wAttributes = new Fl_Menu_Button(250, 40, 84, 20, "Attributes");
  wAttributes->labelsize(12);
  wAttributes->textsize(12);
  wAttributes->callback((Fl_Callback*)cb_wAttributes);
} // Fl_Menu_Button* wAttributes
{ wSlotName = new Fl_Input(75, 81, 155, 19, "Slot Name:");
  wSlotName->labelsize(12);
  wSlotName->textsize(12);
  wSlotName->callback((Fl_Callback*)cb_wSlotName);
  wSlotName->when(FL_WHEN_CHANGED);
} // Fl_Input* wSlotName
{ wEditor = new Fl_Choice(280, 80, 105, 20, "Editor:");
  wEditor->down_box(FL_BORDER_BOX);
  wEditor->labelsize(12);
  wEditor->textsize(12);
  wEditor->menu(menu_wEditor);
} // Fl_Choice* wEditor
{ wHelp = new Fl_Box(15, 116, 370, 54);
  wHelp->box(FL_BORDER_BOX);
  wHelp->labelsize(12);
  wHelp->align(197|FL_ALIGN_INSIDE);
} // Fl_Box* wHelp
{ wAdd = new Fl_Button(240, 185, 64, 20, "Add");
  wAdd->labelsize(12);
  wAdd->callback((Fl_Callback*)cb_wAdd);
} // Fl_Button* wAdd
{ wDone = new Fl_Button(320, 185, 64, 20, "Done");
  wDone->labelsize(12);
  wDone->callback((Fl_Callback*)cb_wDone);
} // Fl_Button* wDone
set_modal();
end();
}

void Fldtk_New_Slot_Dialog::setTemplate(Dtk_Template *tmpl) {
  tmpl_ = tmpl;

wTemplateProto->copy_label(tmpl->id());
Fl_Menu_Item *m;

m = dtkPlatform->specificChoiceMenu(tmpl);
dtkPlatform->updateActivation(m, tmpl);
wSpecific->menu(m);

m = dtkPlatform->methodsChoiceMenu();
dtkPlatform->updateActivation(m, tmpl);
wMethods->menu(m);

m = dtkPlatform->attributesChoiceMenu();
dtkPlatform->updateActivation(m, tmpl);
wAttributes->menu(m);

wSlotName->value("");
wEditor->value(0);
wHelp->label("");
wAdd->deactivate();
}

//
// DyneTK, the Dyne Toolkit
// Copyright (C) 2007 Matthias Melcher
//
